package com.tuyrt.firstcode

import android.os.Bundle
import android.util.Log
import android.widget.TextView
import com.tuyrt.firstcode.common.BaseActivity
import com.tuyrt.firstcode.utils.AppGlobals
import com.tuyrt.firstcode.utils.showToast
import kotlin.concurrent.thread

class MainActivity : BaseActivity() {

    private val textView by lazy {
        findViewById<TextView>(R.id.text)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        textView.setOnClickListener {  }

        //子线程可以在ViewRootImpl还没有被创建之前更新UI；onCreate、onStart,onResume
        thread {
            textView.text = "Main onCreate"
        }

        Log.d("aaaa", "application : "+AppGlobals.getApp())

        R.string.app_name.showToast()
    }

    override fun onResume() {
        super.onResume()
        thread {
            textView.text = "Main onResume"
        }
    }
}